import com.four.bmm.dao.IUserDao;
import com.four.bmm.entity.User;
import com.four.bmm.service.UserService;
import com.four.bmm.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class UserTestDemo {
    SqlSession session=SqlSessionFactoryUtil.getSqlSession();
    IUserDao userDao=session.getMapper(IUserDao.class);
    UserService userService=new UserService();
    @Test
    public void registTest(){
        String username="tom";
        String userpwd="123";
        User user=new User(username,userpwd);
        boolean b=userDao.regist(user);
        if(b){
            System.out.println("ok");
        }else{
            System.out.println("！！");
        }
    }
    @Test
    public void loginTest(){
        String username="lsl";
        String userpwd="123";
        User user=new User(username,userpwd);
        User user1=userDao.login(user);
        System.out.println(user1);
        System.out.println(userService.login(user));
    }


        @Test
        public void testConnection() throws Exception {
            SqlSession session = SqlSessionFactoryUtil.getSqlSession();
            System.out.println(session!=null?"连接成功":"连接失败");
        }


}